<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title>标准编辑</title>

    <link rel="stylesheet" href="${ctx}/static/styles/std_detail.css" type="text/css">

    <script src="${ctx}/static/js/jquery-2.1.1.min.js" type="text/javascript"></script>
    <script src="${ctx}/static/js/pdfobject.min.js"></script>

    <script>
        $(document).ready(function () {
            PDFObject.embed("${ctx}/resource/docs/${std.catStd}/${std.pdfPath}", "#ex");
        });</script>
    <script>
        $('textarea').each(function () {
            this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
        }).on('input', function () {
            this.style.height = 'auto';
            this.style.height = (this.scrollHeight) + 'px';
        });</script>
</head>

<body>
<div class="std-main">
    <div class="container">
        <h5>标准信息编辑</h5>
        <div class="row" style="padding-bottom: 50px">
            <form role="form">
                <div class="input-group">
                    <input type="hidden" name="cat" value="${std.catStd}"/>
                    <c:if test="${std.pdfPath}==''">
                        <span class="label label-danger"> 此标准无关联PDF</span>
                    </c:if>
                    <span class="label label-success" id="pdfPath1">${std.pdfPath}</span>
                    <input type="file" onchange="uploadHead();" id="basicInfoHead" style="display:none;"
                           name="basicInfoHead"/>
                    <input type="hidden" id="basicHeadUrl">&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="#basicInfo" id="uploadBasicInfoHead">添加或更改PDF文件</a>
                </div>
            </form>
            <form id="inputForm" action="${ctx}/std/update" method="post" class="form-horizontal">
                <input type="hidden" name="id" value="${std.id}"/>
                <input type="hidden" name="valid" value="${std.valid}"/>
                <div class="std_edit_detail">
                    <div class="std-info">
                        <div class="input-group">
                            <span class="input-group-addon">中文名称：</span><input type="text" name="titleCn"
                                                                               value="${std.titleCn}"
                                                                               class="form-control"></p>
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">英文名称：</span><input type="text" name="titleEn"
                                                                               value="${std.titleEn}"
                                                                               class="form-control"></p>
                        </div>

                        <div class="input-group">
                            <span class="input-group-addon">标准编号：</span><input type="text" name="name"
                                                                               value="${std.name}"
                                                                               class="form-control"></p>
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">起草单位：</span><input type="text" name="qicao"
                                                                               value="${std.qicao}"
                                                                               class="form-control"></p>
                        </div>

                        <div class="input-group">
                            <span class="input-group-addon">归口单位：</span><input type="text" name="guikou"
                                                                               value="${std.guikou}"
                                                                               class="form-control"></p>
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">发布日期：</span><input type="text" name="publishDate"
                                                                               value="${std.publishDate}"
                                                                               class="form-control"></p>
                            <span class="input-group-addon">生效日期：</span><input type="text" name="effectiveDate"
                                                                               value="${std.effectiveDate}"
                                                                               class="form-control"></p>
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">中标分类：</span><input type="text" name="catCn"
                                                                               value="${std.catCn}"
                                                                               class="form-control"></p>
                            <span class="input-group-addon">标准分类：</span><input type="text" name="catStd"
                                                                               value="${std.catStd}"
                                                                               class="form-control"></p>
                            <span class="input-group-addon">ICS分类：</span><input type="text" name="catIcs"
                                                                                value="${std.catIcs}"
                                                                                class="form-control"></p>
                            <span class="input-group-addon">语言：</span><input type="text" name="language"
                                                                             value="${std.language}"
                                                                             class="form-control"></p>
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">PDF路径：</span><input type="text" name="pdfPath" id="pdfPath2"
                                                                                value="${std.pdfPath}"
                                                                                class="form-control"></p>
                            <span class="input-group-addon">TXT路径：</span><input type="text" name="txtPath"
                                                                                value="${std.txtPath}"
                                                                                class="form-control"></p>
                        </div>
                        <div>
                            <label class="col-sm-2 control-label">引用标准</label>
                            <textarea class="form-control" type="text" name="reference" rows="3">${std.reference}</textarea>
                        </div>
                        <div>
                            <label class="col-sm-2 control-label">领域声明</label>
                            <textarea class="form-control" type="text" name="workField" rows="3">${std.workField}</textarea>
                        </div>
                        <div>
                            <label class="col-sm-2 control-label">关联指标</label>
                            <textarea class="form-control" type="text" name="quotas" rows="3">${std.quotas}</textarea>
                        </div>
                    </div>
                </div>

                <div class="col-md-4">
                <textarea style="white-space:nowrap; overflow:scroll;" cols="44" rows="20">
                    ${std.textOcr}
                </textarea>
                </div>
                <div class="col-md-8">
                    <div id="ex" class="std-pdfshow">
                    </div>
                </div>
                <div class="news-btn-area">
                    <button type="submit" class="btn btn-success info-submit">
                        <span class="glyphicon glyphicon-ok"></span> 发布
                    </button>
                    <button type="reset" class="btn btn-danger">
                        <span class="glyphicon glyphicon-remove"></span> 重置
                    </button>
                </div>
            </form>
        </div>

    </div>
</div>
<script src="${ctx}/static/js/ajaxfileupload.js" type="text/javascript"></script>
<script>
    //上传头像，触发click方法
    $('#uploadBasicInfoHead').on('click', function () {
        $('#basicInfoHead').click();
    });

    function uploadHead() {
        var jsonArrayFinal = JSON.stringify("${std.catStd}");
        $.ajaxFileUpload({
            url: "${ctx}/admin/profile/uploadBasicHead?cat=${std.catStd}",//需要链接到服务器地址

            secureuri: false,
            fileElementId: "basicInfoHead",//文件选择框的id属性
            dataType: 'json',   //json
            success: function (data) {
                $("#pdfPath1").html(data.imagePath);
                $("#pdfPath2").attr("value", data.imagePath);
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert('上传失败！');
            }
        });
    }
    ;
</script>
</body>
</html>
